<?php
class Core_OS {
		/** Shell prompt to display to a user */
		public static $prompt =  "> ";
		
		/** Shall whitespace chars be stripped from the input or not */
		public static $trimEnabled = true;
		
		private static $io_handle;
		
//***************************************************************************************
/**
 * Detects OS type and returns one of the Core_Enum_OSTypes constants as a result
 */
		public static function detectOS()
		{
			// a very basic detection. Probably should be improved.
			
			$uname = strtolower( php_uname() );/* Operating system name */
			
			$osType = Core_Enum_OSTypes::OTHER;
			
			if ( substr($uname, 0, 3) === 'win')			
				$osType = Core_Enum_OSTypes::WINDOWS;			

			if (strpos($uname, 'linux') !== false )
				$osType = Core_Enum_OSTypes::LINUX;
				
			if ( strpos($uname, 'freebsd') !== false )
				$osType = Core_Enum_OSTypes::FREE_BSD;

			if ( strpos($uname, 'solaris') !== false || strpos($uname, 'sunos') !== false ) 
				$osType = Core_Enum_OSTypes::SOLARIS;
				
			return $osType;
		}

}


/* 
 * The following examples were taken from:
 * https://www.amb-net.de/svn/pub/webdev/g3frontendhs/data/include/pear/OS/Guess.php
 */

// {{{ uname examples

// php_uname() without args returns the same as 'uname -a', or a PHP-custom
// string for Windows.
// PHP versions prior to 4.3 return the uname of the host where PHP was built,
// as of 4.3 it returns the uname of the host running the PHP code.
//
// PC RedHat Linux 7.1:
// Linux host.example.com 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
//
// PC Debian Potato:
// Linux host 2.4.17 #2 SMP Tue Feb 12 15:10:04 CET 2002 i686 unknown
//
// PC FreeBSD 3.3:
// FreeBSD host.example.com 3.3-STABLE FreeBSD 3.3-STABLE #0: Mon Feb 21 00:42:31 CET 2000     root@example.com:/usr/src/sys/compile/CONFIG  i386
//
// PC FreeBSD 4.3:
// FreeBSD host.example.com 4.3-RELEASE FreeBSD 4.3-RELEASE #1: Mon Jun 25 11:19:43 EDT 2001     root@example.com:/usr/src/sys/compile/CONFIG  i386
//
// PC FreeBSD 4.5:
// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb  6 23:59:23 CET 2002     root@example.com:/usr/src/sys/compile/CONFIG  i386
//
// PC FreeBSD 4.5 w/uname from GNU shellutils:
// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb  i386 unknown
//
// HP 9000/712 HP-UX 10:
// HP-UX iq B.10.10 A 9000/712 2008429113 two-user license
//
// HP 9000/712 HP-UX 10 w/uname from GNU shellutils:
// HP-UX host B.10.10 A 9000/712 unknown
//
// IBM RS6000/550 AIX 4.3:
// AIX host 3 4 000003531C00
//
// AIX 4.3 w/uname from GNU shellutils:
// AIX host 3 4 000003531C00 unknown
//
// SGI Onyx IRIX 6.5 w/uname from GNU shellutils:
// IRIX64 host 6.5 01091820 IP19 mips
//
// SGI Onyx IRIX 6.5:
// IRIX64 host 6.5 01091820 IP19
//
// SparcStation 20 Solaris 8 w/uname from GNU shellutils:
// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc
//
// SparcStation 20 Solaris 8:
// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc SUNW,SPARCstation-20
//
// Mac OS X (Darwin)
// Darwin home-eden.local 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug  5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC  Power Macintosh
//
// Mac OS X early versions
//